package com.msb.apipassenger.service;

import com.msb.apipassenger.feign.ServicePassengerUserClient;
import com.msb.commons.response.ResponseResult;
import com.msb.commons.response.TokenResult;
import com.msb.commons.util.JwtUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author: chshh
 * @version: 1.0
 */
@Service
public class PassengerUserService {
    @Resource
    private ServicePassengerUserClient passengerUserClient;

    public ResponseResult getUserByAccessToken(String accessToken){
        //解析accessToken,拿到手机号
        TokenResult tokenResult = JwtUtils.parseToken(accessToken);
        String phone = tokenResult.getPhone();
        //根据手机号查询用户信息
        ResponseResult responseResult = passengerUserClient.getUser(phone);
        return ResponseResult.success(responseResult.getData());
    }
}
